﻿using System;
using FU.Capstones.IMS.Web.Common;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.DataContracts;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.EventArgs;

namespace FU.Capstones.IMS.Web.Silverlight.Models
{
    public class OrderDetailModel : ModelBase
    {
        public OrderDetailModel()
        {
            client.InsertOrderCompleted += DoInsertOrderCompleted;
            client.GetWarehouseCollectionCompleted += DoGetWarehouseCollectionCompleted;
            client.GetEmployeeCollectionCompleted += DoGetEmployeeCollectionCompleted;
            client.GetContactCollectionCompleted += DoGetContactCollectionCompleted;
            client.GetSingleOrderCompleted += DoGetSingleOrderCompleted;
            client.GetMaterialCollectionCompleted += DoGetMaterialCollectionCompleted;
        }

        #region get list material
        public event EventHandler<CollectionFeedbackCompletedEventArgs<Material>> GetMaterialCollectionCompleted;
        void DoGetMaterialCollectionCompleted(object sender, CollectionFeedbackCompletedEventArgs<Material> e)
        {
            if (GetMaterialCollectionCompleted != null)
            {
                GetMaterialCollectionCompleted(sender, e);
            }
        }
        public int GetMaterialCollectionAsync(bool isShowAll)
        {
            client.GetMaterialCollectionAsync(isShowAll);
            return WebConstants.MagicNumer;
        }


        #endregion

        #region GetSingleOrder
        public event EventHandler<SingleFeedbackCompletedEventArgs<Order>> GetSingleOrderCompleted;

        void DoGetSingleOrderCompleted(object sender, SingleFeedbackCompletedEventArgs<Order> e)
        {
            if (GetSingleOrderCompleted != null)
            {
                GetSingleOrderCompleted(sender, e);
            }
        }
        public int GetSingleOrderAsync(int orderId)
        {
            client.GetSingleOrderAsync(orderId);
            return WebConstants.MagicNumer;
        }

        #endregion

        #region GetContactCollection

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Contact>> GetContactCollectionCompleted;
        void DoGetContactCollectionCompleted(object sender, CollectionFeedbackCompletedEventArgs<Contact> e)
        {
            if (GetContactCollectionCompleted != null)
            {
                GetContactCollectionCompleted(sender, e);
            }
        }
        public int GetContactCollectionAsync(bool isShowAll)
        {
            client.GetContactCollectionAsync(isShowAll);
            return WebConstants.MagicNumer;
        }

        #endregion

        #region GetEmployeeCollection

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Employee>> GetEmployeeCollectionCompleted;
        void DoGetEmployeeCollectionCompleted(object sender, CollectionFeedbackCompletedEventArgs<Employee> e)
        {
            if (GetEmployeeCollectionCompleted != null)
            {
                GetEmployeeCollectionCompleted(sender, e);
            }
        }
        public int GetEmployeeCollectionAsync(bool isShowAll)
        {
            client.GetEmployeeCollectionAsync(isShowAll);
            return WebConstants.MagicNumer;
        }

        #endregion


        #region GetCollectionWarehouse

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Warehouse>> GetWarehouseCollectionCompleted;
        void DoGetWarehouseCollectionCompleted(object sender, CollectionFeedbackCompletedEventArgs<Warehouse> e)
        {
            if (GetWarehouseCollectionCompleted != null)
            {
                GetWarehouseCollectionCompleted(sender, e);
            }
        }
        public int GetWarehouseCollectionAsync(bool isShowAll)
        {
            client.GetWarehouseCollectionAsync(isShowAll);
            return WebConstants.MagicNumer;
        }

        #endregion


        #region InsertOrder

        public event EventHandler<SingleFeedbackCompletedEventArgs<int>> InsertOrderCompleted;
        void DoInsertOrderCompleted(object sender, SingleFeedbackCompletedEventArgs<int> e)
        {
            if (InsertOrderCompleted != null)
            {
                InsertOrderCompleted(sender, e);
            }
        }

        public int InsertOrderAsync(Order newOrder)
        {
            client.InsertOrderAsync(newOrder);
            return WebConstants.MagicNumer;
        }

        #endregion
    }
}
